package drds.binlog.binlog_event.event;

import drds.binlog.binlog_event.LogByteBlock;
import drds.binlog.common.Authors;
import drds.common.Author;
import lombok.Getter;
import lombok.Setter;

@Author(name = Authors.LI_YANG)
public class RowsQueryLogEvent extends IgnorableLogEvent
{
    @Setter
    @Getter
    private String rowsQuery;

    public RowsQueryLogEvent(LogHeader logHeader, LogByteBlock logByteBlock, FormatDescriptionLogEvent formatDescriptionLogEvent)
    {
        super(logHeader, logByteBlock, formatDescriptionLogEvent);

        final int commonHeaderLength = formatDescriptionLogEvent.commonHeaderLength;
        final int postHeaderLength = formatDescriptionLogEvent.postHeaderLengths[logHeader.logType - 1];

        /*
         * m_rows_query length is stored using only one byte, but that length is
         * ignored and the complete query is read.
         */
        int offset = commonHeaderLength + postHeaderLength + 1;
        int len = logByteBlock.limit() - offset;
        rowsQuery = logByteBlock.getFullString(offset, len, LogByteBlock.ISO_8859_1);
    }


}
